Other Functions
The following functions are available globally.
-
Helper function to ensure that the callback is executed on the main thread.
Declaration
Swift
public func callOnMainThread(_ callback: ((Void) -> Void))
-
Undocumented
-
Undocumented
-
Attempt to create an enum for the given key in the given dictionary, filling presentKeys and errors along the way.
Declaration
Swift
public func createEnum<E: RawRepresentable>(type: E.Type, for key: String, in json: FHIRJSON, context: inout FHIRInstantiationContext) -> E?Parameters
typeThe enum type to create (as an array)
keyThe JSON key to look at in
jsonjsonThe JSON dictionary to inspect
contextThe instantiation context to use
Return Value
An array of enums, or nil
-
Attempt to create an array of enums for the given key in the given dictionary, populating presentKeys and errors appropriately.
Declaration
Swift
public func createEnums<E: RawRepresentable>(of type: E.Type, for key: String, in json: FHIRJSON, context: inout FHIRInstantiationContext) -> [E]?Parameters
typeThe enum type to create (as an array)
keyThe JSON key to look at in
jsonjsonThe JSON dictionary to inspect
contextThe instantiation context to use
Return Value
An array of enums, or nil
-
Undocumented
-
Inspects the given dictionary for an array with the given key, and if successful instantiates an array of the desired FHIR objects.
Unable to make this a class method on FHIRAbstractBase as it would need to be implemented on every subclass in order to not return
FHIRAbstractBaseall the time.Declaration
Swift
public func instantiate<T: FHIRAbstractBase>(type: T.Type, for key: String, in json: FHIRJSON, presentKeys: inout Set<String>, errors: inout [FHIRValidationError], owner: FHIRAbstractBase? = nil) throws -> [T]?Parameters
typeThe FHIR object that is expected
keyThe key for which to look in
jsonjsonThe JSON dictionary to search through
presentKeysAn inout set of keys found in the JSON
errorsAn inout array of validation errors found
ownerThe FHIRAbstractBase owning the new instance, if appropriate
Return Value
An array of the desired FHIRAbstractBase subclasses (or nil)
-
Inspects the given dictionary for the value of the given key, then instantiates the desired type if possible.
Cannot implement this as
init?() throwsbecause it needs to inspectP.JSONTypebefore callinginit(), which is not possible.Declaration
Swift
public func createInstance<P: FHIRJSONType>(type: P.Type, for key: String, in json: FHIRJSON, context: inout FHIRInstantiationContext, owner: FHIRAbstractBase?) -> P?Parameters
typeThe primitive type that is wanted
keyThe key for which to look in
jsonjsonThe JSON dictionary to search through
contextThe instantiation context to use
ownerThe FHIRAbstractBase owning the new instance, if appropriate
Return Value
An instance of the appropriate FHIRPrimitive, or nil
-
Inspects the given dictionary for an array with the given key, and if successful instantiates an array of the desired types.
This method cannot be part of FHIRJSONType because it would have to be implemented by every resource class, instead of just the base class (error is “Protocol requirement cannot be satisfied by non-final class because it uses ‘Self’ in a non-parameter, non-result type position).
Declaration
Swift
public func createInstances<P: FHIRJSONType>(of type: P.Type, for key: String, in json: FHIRJSON, context: inout FHIRInstantiationContext, owner: FHIRAbstractBase?) -> [P]?Parameters
typeThe primitive type that is expected
keyThe key for which to look in
jsonjsonThe JSON dictionary to search through
contextThe instantiation context to use
ownerThe FHIRAbstractBase owning the new instance, if appropriate
Return Value
An array of the appropriate FHIRPrimitive, or nil
-
Execute a
print(), prepending filename, line and function/method name, ifDEBUGis defined.Declaration
Swift
public func fhir_logIfDebug(_ message: @autoclosure () -> String, function: String = #function, file: String = #file, line: Int = #line) -
Execute a
print(), prepending filename, line and function/method name andWARNING
prepended.Declaration
Swift
public func fhir_warn(_ message: @autoclosure () -> String, function: String = #function, file: String = #file, line: Int = #line)
View on GitHub
Install in Dash
Other Functions Reference